//管理设备数据相关
import {defineStore} from "pinia";
import {ref} from "vue";

export const useDataPublicStore=defineStore('dataPublic',()=>{

        //1.定义菜单的数据的state

        const dataList=ref([]);
        const dataObject=ref({});
        const dataNumber=ref(0);
        const dataString=ref('');
        // 用于cameraCapture模块的文件存储
        const photoFileList=ref([])
        // 用于upload模块的文件存储
        const uploadFileList=ref([]);


        // 上传下载进度条
        const onUploadProgress=ref(0);
        const onDownloadProgress=ref(0);

        const setOnUploadProgress=(data:number)=>{
            onUploadProgress.value=data;
        }
        const setOnDownloadProgress=(data:number)=>{
            onDownloadProgress.value=data;
        }


        //根据pid及level获取菜单树
        const saveDataList=(data:[])=>{
            dataList.value=data;
        }


        const saveDataObject=(data:{})=>{
            dataObject.value=data;
        }

        const saveDataNumber=(data:number)=>{
            dataNumber.value=data;
        }
        const saveDataString=(data:string)=>{
            dataString.value=data;
        }

        const setUploadFileList=(data:[])=>{
            uploadFileList.value=data;
        }

        const setPhotoFiles=(data:[])=>{
            photoFileList.value=data;
        }



        //3.以对象的格式把state和action return
        return {
            dataList,dataObject,dataNumber,dataString,
            saveDataNumber,saveDataString,saveDataList,saveDataObject
            ,uploadFileList,setUploadFileList,setPhotoFiles,photoFileList,
            setOnUploadProgress,setOnDownloadProgress,onUploadProgress,onDownloadProgress
        }
    }
    // ,
    // {
    //     persist:true
    // }

)